package com.tedu.bill.demo1;

import java.util.HashMap;

/**
 * Author：毕龙
 * Date: 2024/5/17 10:49
 */
public class Testquestion55 {
    public static void main(String[] args) {
        String str = "aaabbbbbcccccdddddihhhccc";

        HashMap<Character, Integer> map = new HashMap<>();
        int count = 0;
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            //该字符不存在则添加到sb中
            if (!map.containsKey(c)){
                map.put(c,++count);
                //从开始添加的位置到整个字符串结束看有多少个该字符
                for (int j = i+1; j < str.length(); j++) {
                    //获取后面相同的字符
                   char c1 = str.charAt(j);
                    if (c == c1){
                        //统计个数
                        count++;
                    }
                }

                map.put(c,count);

                count=0;
            }

        }
        System.out.println(map.toString());
    }
}
